package com.zoe.onelink.core.util.http;


import com.zoe.onelink.common.exception.http.HttpClientException;
import com.zoe.onelink.core.util.http.model.HttpClientEntity;
import com.zoe.onelink.core.util.http.model.HttpClientResponse;

import java.io.IOException;
import java.net.http.HttpConnectTimeoutException;
import java.net.http.HttpTimeoutException;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2021</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2021-10-18
 */
public interface HttpClient {

    /**
     * 同步请求
     *
     * @param httpClientEntity 请求参数
     * @param returnType       返回类型
     * @return .
     * @throws HttpConnectTimeoutException 建立连接超时
     * @throws HttpTimeoutException        请求超时
     * @throws IOException                 其他异常
     */
    <R> HttpClientResponse<R> doRequest(HttpClientEntity httpClientEntity, Class<R> returnType) throws HttpClientException;

    /**
     * 异步请求
     *
     * @param httpClientEntity 请求参数
     * @param callback         请求完成回调
     */
    <R> void doAsyncRequest(HttpClientEntity httpClientEntity, Class<R> returnType, HttpClientAsyncCallback<R> callback);

}
